import request from './request'
import { cart } from '@/model/cartModel'

export const searchCartList = (user_id: number) => {
  return request({
    url: 'cart',
    method: 'GET',
    params: { user_id }
  })
}

export const searchGoodsInfoByGoodsInfoId = (goodsInfo_ids: number[]) => {
  return request({
    url: 'cart/search',
    method: 'GET',
    params: { goodsInfo_ids }
  })
}

export const insertCartList = (cartList: cart[]) => {
  return request({
    url: 'cart/add',
    method: 'PUT',
    data: { cartList }
  })
}

export const deleteCart = (goodsInfo_id: number, user_id: number) => {
  return request({
    url: 'cart/delete',
    method: 'DELETE',
    data: { goodsInfo_id, user_id }
  })
}

export const deleteCartAll = (user_id: number) => {
  return request({
    url: 'cart/deleteAll',
    method: 'DELETE',
    data: { user_id }
  })
}
